/**
 * 2006-9-3 13:35:19
 * SearchForm.java
 */
package org.lilystudio.veryftp.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 * @author Samson
 * 
 */
public class SearchForm extends ActionForm {

	private static final long serialVersionUID = 1L;

	private String searchString;

	/**
	 * @return Returns the searchString.
	 */
	public String getSearchString() {
		return searchString;
	}

	/**
	 * @param searchString
	 *            The searchString to set.
	 */
	public void setSearchString(String searchString) {
		this.searchString = searchString;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping,
	 *      javax.servlet.http.HttpServletRequest)
	 */
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		this.searchString = null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping,
	 *      javax.servlet.http.HttpServletRequest)
	 */
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		if (searchString == null || searchString.length() < 1) {
			errors.add("searchString", new ActionMessage(
					"veryftp.error.searchString.required"));
		}
		return errors;
	}

}
